package com.thf.service.impl;

import com.thf.dao.impl.ContactDaoImpl;
import com.thf.model.ContactModels;
import com.thf.service.ContactService;
import com.thf.util.FileDataUtil;

import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

public class ContactServiceImpl implements ContactService {

    ContactDaoImpl cdi =new ContactDaoImpl();
    @Override
    public String[] getContactData(String inPath, String outPath, String pathName) {
        String filePath = cdi.createFileData(inPath,outPath,pathName);
        String[] fileData = null ;
        try {
            fileData = FileDataUtil.getFileData(filePath);
        } catch (IOException e) {
            e.printStackTrace();
        }
        return fileData ;
    }

    @Override
    public List<ContactModels> setContactData() {
        List<ContactModels> list = new ArrayList<>() ;
        String[] contactData = getContactData("D:/test/contactData.txt", "D:\\huarui03\\web\\WEB-INF\\note", "contactData.txt");
        for (int i = 0; i <contactData.length; i++) {
            ContactModels contactModels = new ContactModels(contactData[i]);
            list.add(contactModels);
        }
        return list ;
    }
}
